import { container } from "tsyringe"
import { FloatyWindow } from "../autox/floatWindow"

export function updateFloat(data: { currentApp?: string, currentAppPage?: string, currentTask?: string, currentRoom?: string, currentStatus?: string, currentResult?: string, kwaiCurrentMoney?: string, kwaiTodayCount?: string, kwaiTodayMoney?: string, nebulaCurrentMoney?: string, nebulaTodayCount?: string, nebulaTodayMoney?: string, tip?: string, toast?: string }) {
    const floatWindow = container.resolve(FloatyWindow)
    console.log(data)
    floatWindow.emit('UPDATE_FLOAT_WINDOW_STATE_CHANGE', data)
}

export function getInputClip() {
    const link = getClip()
    if (link) return link;
    let dis = threads.disposable()
    var w = floaty.window(
        `<frame gravity="center" bg="#ffffff">
          <text id="text"></text>
        </frame>`
    );
    ui.run(function () {
        w.requestFocus();
        setTimeout(() => {
            dis.setAndNotify(getClip())
            w.disableFocus();
            w.close();
        }, 1);
    });
    const link2 = dis.blockedGet()
    return link2;
}